{"ast":null,"code":"import _extends from \"@babel/runtime/helpers/esm/extends\";\nimport _objectWithoutPropertiesLoose from \"@babel/runtime/helpers/esm/objectWithoutPropertiesLoose\";\nconst _excluded = [\"boundaryCount\", \"componentName\", \"count\", \"defaultPage\", \"disabled\", \"hideNextButton\", \"hidePrevButton\", \"onChange\", \"page\", \"showFirstButton\", \"showLastButton\", \"siblingCount\"];\nimport { unstable_useControlled as useControlled } from '@mui/utils';\nexport default function usePagination() {\n  let props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};\n  // keep default values in sync with @default tags in Pagination.propTypes\n  const {\n      boundaryCount = 1,\n      componentName = 'usePagination',\n      count = 1,\n      defaultPage = 1,\n      disabled = false,\n      hideNextButton = false,\n      hidePrevButton = false,\n      onChange: handleChange,\n      page: pageProp,\n      showFirstButton = false,\n      showLastButton = false,\n      siblingCount = 1\n    } = props,\n    other = _objectWithoutPropertiesLoose(props, _excluded);\n  const [page, setPageState] = useControlled({\n    controlled: pageProp,\n    default: defaultPage,\n    name: componentName,\n    state: 'page'\n  });\n  const handleClick = (event, value) => {\n    if (!pageProp) {\n      setPageState(value);\n    }\n    if (handleChange) {\n      handleChange(event, value);\n    }\n  };\n\n  // https://dev.to/namirsab/comment/2050\n  const range = (start, end) => {\n    const length = end - start + 1;\n    return Array.from({\n      length\n    }, (_, i) => start + i);\n  };\n  const startPages = range(1, Math.min(boundaryCount, count));\n  const endPages = range(Math.max(count - boundaryCount + 1, boundaryCount + 1), count);\n  const siblingsStart = Math.max(Math.min(\n  // Natural start\n  page - siblingCount,\n  // Lower boundary when page is high\n  count - boundaryCount - siblingCount * 2 - 1),\n  // Greater than startPages\n  boundaryCount + 2);\n  const siblingsEnd = Math.min(Math.max(\n  // Natural end\n  page + siblingCount,\n  // Upper boundary when page is low\n  boundaryCount + siblingCount * 2 + 2),\n  // Less than endPages\n  endPages.length > 0 ? endPages[0] - 2 : count - 1);\n\n  // Basic list of items to render\n  // e.g. itemList = ['first', 'previous', 1, 'ellipsis', 4, 5, 6, 'ellipsis', 10, 'next', 'last']\n  const itemList = [...(showFirstButton ? ['first'] : []), ...(hidePrevButton ? [] : ['previous']), ...startPages,\n  // Start ellipsis\n  // eslint-disable-next-line no-nested-ternary\n  ...(siblingsStart > boundaryCount + 2 ? ['start-ellipsis'] : boundaryCount + 1 < count - boundaryCount ? [boundaryCount + 1] : []),\n  // Sibling pages\n  ...range(siblingsStart, siblingsEnd),\n  // End ellipsis\n  // eslint-disable-next-line no-nested-ternary\n  ...(siblingsEnd < count - boundaryCount - 1 ? ['end-ellipsis'] : count - boundaryCount > boundaryCount ? [count - boundaryCount] : []), ...endPages, ...(hideNextButton ? [] : ['next']), ...(showLastButton ? ['last'] : [])];\n\n  // Map the button type to its page number\n  const buttonPage = type => {\n    switch (type) {\n      case 'first':\n        return 1;\n      case 'previous':\n        return page - 1;\n      case 'next':\n        return page + 1;\n      case 'last':\n        return count;\n      default:\n        return null;\n    }\n  };\n\n  // Convert the basic item list to PaginationItem props objects\n  const items = itemList.map(item => {\n    return typeof item === 'number' ? {\n      onClick: event => {\n        handleClick(event, item);\n      },\n      type: 'page',\n      page: item,\n      selected: item === page,\n      disabled,\n      'aria-current': item === page ? 'true' : undefined\n    } : {\n      onClick: event => {\n        handleClick(event, buttonPage(item));\n      },\n      type: item,\n      page: buttonPage(item),\n      selected: false,\n      disabled: disabled || item.indexOf('ellipsis') === -1 && (item === 'next' || item === 'last' ? page >= count : page <= 1)\n    };\n  });\n  return _extends({\n    items\n  }, other);\n}","map":{"version":3,"names":["_extends","_objectWithoutPropertiesLoose","_excluded","unstable_useControlled","useControlled","usePagination","props","boundaryCount","componentName","count","defaultPage","disabled","hideNextButton","hidePrevButton","onChange","handleChange","page","pageProp","showFirstButton","showLastButton","siblingCount","other","setPageState","controlled","default","name","state","handleClick","event","value","range","start","end","length","Array","from","_","i","startPages","Math","min","endPages","max","siblingsStart","siblingsEnd","itemList","buttonPage","type","items","map","item","onClick","selected","undefined","indexOf"],"sources":["/data/messenger.client/node_modules/@mui/material/esm/usePagination/usePagination.js"],"sourcesContent":["import _extends from \"@babel/runtime/helpers/esm/extends\";\nimport _objectWithoutPropertiesLoose from \"@babel/runtime/helpers/esm/objectWithoutPropertiesLoose\";\nconst _excluded = [\"boundaryCount\", \"componentName\", \"count\", \"defaultPage\", \"disabled\", \"hideNextButton\", \"hidePrevButton\", \"onChange\", \"page\", \"showFirstButton\", \"showLastButton\", \"siblingCount\"];\nimport { unstable_useControlled as useControlled } from '@mui/utils';\nexport default function usePagination(props = {}) {\n  // keep default values in sync with @default tags in Pagination.propTypes\n  const {\n      boundaryCount = 1,\n      componentName = 'usePagination',\n      count = 1,\n      defaultPage = 1,\n      disabled = false,\n      hideNextButton = false,\n      hidePrevButton = false,\n      onChange: handleChange,\n      page: pageProp,\n      showFirstButton = false,\n      showLastButton = false,\n      siblingCount = 1\n    } = props,\n    other = _objectWithoutPropertiesLoose(props, _excluded);\n  const [page, setPageState] = useControlled({\n    controlled: pageProp,\n    default: defaultPage,\n    name: componentName,\n    state: 'page'\n  });\n  const handleClick = (event, value) => {\n    if (!pageProp) {\n      setPageState(value);\n    }\n    if (handleChange) {\n      handleChange(event, value);\n    }\n  };\n\n  // https://dev.to/namirsab/comment/2050\n  const range = (start, end) => {\n    const length = end - start + 1;\n    return Array.from({\n      length\n    }, (_, i) => start + i);\n  };\n  const startPages = range(1, Math.min(boundaryCount, count));\n  const endPages = range(Math.max(count - boundaryCount + 1, boundaryCount + 1), count);\n  const siblingsStart = Math.max(Math.min(\n  // Natural start\n  page - siblingCount,\n  // Lower boundary when page is high\n  count - boundaryCount - siblingCount * 2 - 1),\n  // Greater than startPages\n  boundaryCount + 2);\n  const siblingsEnd = Math.min(Math.max(\n  // Natural end\n  page + siblingCount,\n  // Upper boundary when page is low\n  boundaryCount + siblingCount * 2 + 2),\n  // Less than endPages\n  endPages.length > 0 ? endPages[0] - 2 : count - 1);\n\n  // Basic list of items to render\n  // e.g. itemList = ['first', 'previous', 1, 'ellipsis', 4, 5, 6, 'ellipsis', 10, 'next', 'last']\n  const itemList = [...(showFirstButton ? ['first'] : []), ...(hidePrevButton ? [] : ['previous']), ...startPages,\n  // Start ellipsis\n  // eslint-disable-next-line no-nested-ternary\n  ...(siblingsStart > boundaryCount + 2 ? ['start-ellipsis'] : boundaryCount + 1 < count - boundaryCount ? [boundaryCount + 1] : []),\n  // Sibling pages\n  ...range(siblingsStart, siblingsEnd),\n  // End ellipsis\n  // eslint-disable-next-line no-nested-ternary\n  ...(siblingsEnd < count - boundaryCount - 1 ? ['end-ellipsis'] : count - boundaryCount > boundaryCount ? [count - boundaryCount] : []), ...endPages, ...(hideNextButton ? [] : ['next']), ...(showLastButton ? ['last'] : [])];\n\n  // Map the button type to its page number\n  const buttonPage = type => {\n    switch (type) {\n      case 'first':\n        return 1;\n      case 'previous':\n        return page - 1;\n      case 'next':\n        return page + 1;\n      case 'last':\n        return count;\n      default:\n        return null;\n    }\n  };\n\n  // Convert the basic item list to PaginationItem props objects\n  const items = itemList.map(item => {\n    return typeof item === 'number' ? {\n      onClick: event => {\n        handleClick(event, item);\n      },\n      type: 'page',\n      page: item,\n      selected: item === page,\n      disabled,\n      'aria-current': item === page ? 'true' : undefined\n    } : {\n      onClick: event => {\n        handleClick(event, buttonPage(item));\n      },\n      type: item,\n      page: buttonPage(item),\n      selected: false,\n      disabled: disabled || item.indexOf('ellipsis') === -1 && (item === 'next' || item === 'last' ? page >= count : page <= 1)\n    };\n  });\n  return _extends({\n    items\n  }, other);\n}"],"mappings":"AAAA,OAAOA,QAAQ,MAAM,oCAAoC;AACzD,OAAOC,6BAA6B,MAAM,yDAAyD;AACnG,MAAMC,SAAS,GAAG,CAAC,eAAe,EAAE,eAAe,EAAE,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,UAAU,EAAE,MAAM,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,cAAc,CAAC;AACrM,SAASC,sBAAsB,IAAIC,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